/*
 * ReceiverRaw.cpp
 *
 *  Created on: 03.11.2011
 *      Author: Pavel Sinay
 */

#include <iostream>

#include "ReceiverSocket.h"
#include "../NetException.h"
#include "../constants.h"

namespace net {

ReceiverSocket::ReceiverSocket() {
}

ReceiverSocket::~ReceiverSocket() {
}

void ReceiverSocket::onClientAccepted(Socket *client_socket) {
	std::vector<char> rx_message;
	std::vector<char> tx_message;
	try {
		client_socket->receiveMessage(rx_message);
		onRawReceived(rx_message, tx_message);
		client_socket->sendMessage(tx_message);
		client_socket->disconnect();
	} catch (NetException e) {
		std::cerr << e.what() << std::endl;
	} catch (...) {
		std::cerr << "Unknown exception" << std::endl;
	}
}

}
